home *** CD-ROM | disk | FTP | other *** search
- Path: holly.ACNS.ColoState.EDU!not-for-mail
- From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
- Newsgroups: comp.lang.c++
- Subject: Re: getch() and cin
- Date: 19 Jan 1996 01:20:02 -0700
- Organization: Colorado State University, Fort Collins, CO 80523
- Message-ID: <4dnk7i$36ha@holly.ACNS.ColoState.EDU>
- References: <4dncee$4g2@news.cencom.net>
- NNTP-Posting-Host: holly.acns.colostate.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Will Senn (wsenn@cencom.net) wrote:
- : I would appreciate it if someone could tell me if there is a way
- : to make cin read input without line buffering (waiting for the carriage
- : return)? I know all about getch() in conio.h, however I would prefer
- : sticking to stream input included in iostream.h. Any help along these lines
- : would be greatly appreciated.
-
- : Before anyone freaks, I spent several hours with the various search
- : engines on the web as well as looking through a ton of related newsgroups
- : before I posted this seemingly obvious question. The closest I came to an
- : answer was a reference to a FAQ 309, a depressingly hard to find faq, quoted
- : in the C++ Faq.
-
- : Thanks for any help,
- ------------------------------------
-
- void main()
- {
- char Temp;
-
- cin.get(Temp);
- while(Temp != '\n') cin.get(Temp);
-
- return;
- }
- -------------------------------------
-
- This will read a character at a time until the newline. The get()
- member is what you want. Questions?
-
- // ------------ BEGIN SIGNATURE ---------------
- #include <iostream.h>
- void main()
- {
- cout<<"\aName:\tCorby S. Hudnall\n";
- cout<<"School:\tColorado State University\n";
- cout<<"EMail\tcorbyh@holly.colostate.edu\n";
- cout<<"URL\thttp://holly.colostate.edu/~corbyh/\n";
- }
- // ------------- END SIGNATURE ----------------
-
-